Hello,
I want to plot a categorical variable with 100 potential values (in the full dataset) over time for one individual in a panel dataset. The idea is to make this kind of plot for 20 individuals to get a sense of transition dynamics of individuals across the categorical values. Here is a minimum working example for one example individual:

The issue is that not all y-axis values are labeled, and given the large number of possible categorical values I don't want to manually specify the y-axis labels -- I want code that only plots the values that a given individual takes on. I’m also interested in general advice on plotting categorical variables over time for a single individual (i.e. other graph types). Thanks,
Santosh
I want to plot a categorical variable with 100 potential values (in the full dataset) over time for one individual in a panel dataset. The idea is to make this kind of plot for 20 individuals to get a sense of transition dynamics of individuals across the categorical values. Here is a minimum working example for one example individual:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte MEM_ID float MONTH_SLOT long INDUSTRY_OF_OCCUPATION 1 730 6 1 726 2 1 722 2 1 718 5 1 714 5 1 710 5 1 706 5 1 702 5 1 698 6 1 694 7 1 691 7 1 687 7 1 683 7 1 679 7 1 675 5 1 671 7 1 667 7 1 661 1 1 657 1 1 653 . 1 649 . end format %tm MONTH_SLOT label values INDUSTRY_OF_OCCUPATION INDUSTRY_OF_OCCUPATION label def INDUSTRY_OF_OCCUPATION 1 "Cement, Tiles, Bricks, Ceramics, Glass and other construction materials", modify label def INDUSTRY_OF_OCCUPATION 2 "Data Not Available", modify label def INDUSTRY_OF_OCCUPATION 5 "Real Estate & Construction", modify label def INDUSTRY_OF_OCCUPATION 6 "Retail Trade", modify label def INDUSTRY_OF_OCCUPATION 7 "Travel and Tourism", modify sort MEM_ID MONTH_SLOT set graphics on twoway scatter INDUSTRY_OF_OCCUPATION MONTH_SLOT, ylabel(, valuelabel labsize(vsmall) angle(0)) xlabel(, labsize(small))
The issue is that not all y-axis values are labeled, and given the large number of possible categorical values I don't want to manually specify the y-axis labels -- I want code that only plots the values that a given individual takes on. I’m also interested in general advice on plotting categorical variables over time for a single individual (i.e. other graph types). Thanks,
Santosh
Comment